/**
 * A GT print job that compares using rank
 * @author Matt Dye
 *
 */
public class GTPrintJob extends SimplePrintJob {
	public static final int DEAN = 2;
	public static final int PROFESSOR = 1;
	public static int TA = 0;
	private int rank;
	
	public GTPrintJob(String name, int pages, int rank)
	{
		super(name,pages);
		if(rank == 2)
		{
			this.rank = DEAN;
		}
		else if(rank == 1)
		{
			this.rank = PROFESSOR;
		}
		else
			this.rank = TA;
	}
	
	/**
	 * compareTo is overridden to put the Dean first and others behind it
	 * 
	 * @param What is being compared
	 */
	@Override
	public int compareTo(SimplePrintJob o) {
		
		if(o instanceof GTPrintJob)
		{
			GTPrintJob job = (GTPrintJob)o;
			if(this.rank > job.getRank())
				return -1;
			else if(this.rank < job.getRank())
				return 1;
			else
			{
				if(this.getPages() < o.getPages())
					return -1;
				else if(this.getPages() > o.getPages())
					return 1;
				else 
					return 0;
			}
				
		}
		else
		{
			if(this.getPages() < o.getPages())
				return -1;
			else if(this.getPages() > o.getPages())
				return 1;
			else 
				return 0;
		}
	}
	
	@Override
	public String toString()
	{
		return "Name: " + this.getName() + " Pages: " 
		+ this.getPages() + " pages " + "Rank: " + this.getRank();
	}
/**
 * Returns rank
 * @return Rank
 */
	public int getRank() {
		return rank;
	}
/**
 * Sets the rank
 * @param rank
 */
	public void setRank(int rank) {
		this.rank = rank;
	}
}
